﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Data;
using System.IO;
using System.Linq;
using Cinch;

namespace Anata.Client
{
    /// <summary>
    /// </summary>
    public class FreeGiftFilterViewModel : ViewModelBase
    {
        #region Data
		#region Data.Primitives
		#endregion

        #region Data.Rules
		#endregion
        
        #region Data.VMs
        private DispatcherNotifiedObservableCollection<FreeGiftViewModel> freeGifts;
        private ICollectionView freeGiftsCV;
        #endregion

        #region Data.Services
        private IMessageBoxService messageBoxService;
        private IUIVisualizerService uiVisualizerService;
        #endregion

        #endregion

        #region Constructor
        [ImportingConstructor]
        public FreeGiftFilterViewModel(
            IMessageBoxService messageBoxService,
            IUIVisualizerService uiVisualizerService)
        {
            #region Constructor.SetupServices
            this.messageBoxService = messageBoxService;
            this.uiVisualizerService = uiVisualizerService;
            #endregion

            #region Constructor.SetupCommands
            FreeGiftSelectCommand = new SimpleCommand<Object, Object>(CanExecuteFreeGiftSelectCommand, ExecuteFreeGiftSelectCommand);
            #endregion

            #region Constructor.SetupDataWrappers
            #endregion

            #region Constructor.SetupValidationRules
            #endregion

            #region Constructor.SetupVMs
            FreeGifts = new DispatcherNotifiedObservableCollection<FreeGiftViewModel>();
            FreeGiftsCV = CollectionViewSource.GetDefaultView(FreeGifts);
            #endregion

            //debug use
            FreeGiftViewModel fvm = null;
            for (int i = 1; i < 11; i++)
            {
                fvm = new FreeGiftViewModel(
                    messageBoxService,
                    uiVisualizerService);
                fvm.IdFreeGift.DataValue = i;
                fvm.Nama.DataValue = "Free Gift " + i;
                fvm.IdJenisStok.DataValue = i;
                fvm.Kuantitas.DataValue = i + 1;
                FreeGifts.Add(fvm);
            }
        }
        #endregion

        #region Public Properties

        #region Public.Commands
        public SimpleCommand<Object, Object> FreeGiftSelectCommand { get; set; }
        #endregion

        #region Public.ViewMode
        #endregion

        #region Public.Data
        #endregion

        #region Public.CachedCollection
        #endregion

        #region Public.DataVM
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs freeGiftsChangeArgs =
            ObservableHelper.CreateArgs<FreeGiftFilterViewModel>(x => x.FreeGifts);
        public DispatcherNotifiedObservableCollection<FreeGiftViewModel> FreeGifts
        {
            get { return freeGifts; }
            set
            {
                freeGifts = value;
                NotifyPropertyChanged(freeGiftsChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs freeGiftsCVChangeArgs =
            ObservableHelper.CreateArgs<FreeGiftFilterViewModel>(x => x.FreeGiftsCV);
        public ICollectionView FreeGiftsCV
        {
            get { return freeGiftsCV; }
            set
            {
                freeGiftsCV = value;
                NotifyPropertyChanged(freeGiftsCVChangeArgs);
            }
        }
        #endregion

        #endregion

        #region Command Handlers
        private bool CanExecuteFreeGiftSelectCommand(Object args)
        {
            return true;
        }
        /// <summary>
        /// </summary>
        private void ExecuteFreeGiftSelectCommand(Object args)
        {
        }
        #endregion

        #region Private Methods
        //private void ViewAwareStatusService_ViewLoaded()
        //{
        //    konsumens = new DispatcherNotifiedObservableCollection<KonsumenViewModel>();
        //    KonsumenViewModel kvm = null;
        //    for (int i = 0; i < 10; i++)
        //    {
        //        kvm = new KonsumenViewModel();
        //        kvm.IdKonsumen.DataValue = i;
        //        kvm.Nama.DataValue = "Konsumen " + i;
        //        kvm.Alamat.DataValue = "Alamat " + i;
        //        konsumens.Add(new KonsumenViewModel());
        //    }
        //    //LoadedKonsumenCV = CollectionViewSource.GetDefaultView(loadedKonsumen);
        //}


        #endregion

        #region Overrides
        #endregion

        #region EditableValidatingViewModelBase overrides
        #endregion
    }

}
